package com.zhaohang.cn.utils;


import android.media.AudioManager;
import android.media.SoundPool;
import android.support.v7.app.AppCompatActivity;

import com.zhaohang.cn.zhaohangapp.CompontApplayCation;
import com.zhaohang.cn.zhaohangapp.R;

/**
 * 作者: 赵航
 * 创建时间: 2018/10/20 15:59
 * 描述:
 */


public class UmsicUtils {

    private static final UmsicUtils instance = new UmsicUtils();
    private SoundPool mSoundPool;
    private int mDuanSound;
    private int mYuluSound;

    //这里提供了一个供外部访问本class的静态方法，可以直接访问
    public static UmsicUtils getInstance(){
        return instance;
    }

    public void musicPlay(boolean isPaly){

        if (mSoundPool==null) {
            mSoundPool = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
            //预加载音乐
            mDuanSound = mSoundPool.load(CompontApplayCation.context, R.raw.duan, 1);
        }

        if (isPaly){
            mSoundPool.play(mDuanSound, 1, 1, 0, 0, 1);
        }



//        mYuluSound = mSoundPool.load(CompontApplayCation.context, R.raw.yulu, 1);
    }
}
